﻿using System;

namespace AgFractal.Controls
{
    public partial class NewFractalUserControl : PopupUserControl
    {
        public NewFractalUserControl()
        {
            InitializeComponent();
            lb.OnMouseDoubleClick += (s, e) => { if (lb.SelectedItem != null) DoOk(); };
        }

        private void CancelButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Close(false);
        }

        private void OKButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            DoOk();
        }

        private void DoOk()
        {
            Close(true);
            if (OnOk != null)
                OnOk((FractalEntry)lb.SelectedItem);
        }

        internal Action<FractalEntry> OnOk;
    }
}